package templates;

{packageName}.controller;
 
import ${packageName}.entity.${entityName};
import ${packageName}.service.${entityName}Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import javax.annotation.Resource;
 
/**
* @author heguoqin
* @date ${currentTime}
* ${tableComment}控制器
* 此控制器负责处理与 ${tableComment} 相关的 HTTP 请求
*/
@RestController
@RequestMapping("/${entityName?uncap_first}")
@Api(tags = "${tableComment}管理接口")
public class ${entityName}Controller {
    @Resource
    private ${entityName}Service ${entityName?uncap_first}Service;
 
    /**
    * 根据 ID 获取 ${tableComment}
    * 该接口通过传入的 ID 从数据库中查询对应的 ${tableComment} 记录
    * @param id ${tableComment}的 ID
    * @return ${tableComment}实体
    */
    @GetMapping("/{id}")
    @ApiOperation(value = "根据 ID 获取 ${tableComment}", notes = "通过传入的 ID 从数据库中查询对应的 ${tableComment} 记录")
    public ${entityName} get${entityName}ById(@PathVariable String id) {
        return ${entityName?uncap_first}Service.get${entityName}ById(id);
    }
 
    /**
    * 保存 ${tableComment}
    * 该接口将传入的 ${tableComment} 实体保存到数据库中
    * @param ${entityName?uncap_first} ${tableComment}实体
    * @return 保存结果
    */
    @PostMapping
    @ApiOperation(value = "保存 ${tableComment}", notes = "将传入的 ${tableComment} 实体保存到数据库中")
    public boolean save${entityName}(@RequestBody ${entityName} ${entityName?uncap_first}) {
        return ${entityName?uncap_first}Service.save${entityName}(${entityName?uncap_first});
    }
 
    /**
    * 更新 ${tableComment}
    * 该接口根据传入的 ${tableComment} 实体更新数据库中对应的记录
    * @param ${entityName?uncap_first} ${tableComment}实体
    * @return 更新结果
    */
    @PutMapping
    @ApiOperation(value = "更新 ${tableComment}", notes = "根据传入的 ${tableComment} 实体更新数据库中对应的记录")
    public boolean update${entityName}(@RequestBody ${entityName} ${entityName?uncap_first}) {
        return ${entityName?uncap_first}Service.update${entityName}(${entityName?uncap_first});
    }
 
    /**
    * 根据 ID 删除 ${tableComment}
    * 该接口根据传入的 ID 从数据库中删除对应的 ${tableComment} 记录
    * @param id ${tableComment}的 ID
    * @return 删除结果
    */
    @DeleteMapping("/{id}")
    @ApiOperation(value = "根据 ID 删除 ${tableComment}", notes = "根据传入的 ID 从数据库中删除对应的 ${tableComment} 记录")
    public boolean delete${entityName}ById(@PathVariable String id) {
        return ${entityName?uncap_first}Service.delete${entityName}ById(id);
    }
}